package com.hyc.cloud.controller;

import com.hyc.cloud.Service.paymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class pymentHystrixController {
    @Resource
   private paymentService paymentService;
    @Value("${server.port}")
    private  String server_port;
    @GetMapping(value = "/payment/hystrix/ok/{id}")
    public String paymentinfo_ok (@PathVariable("id") Integer id)
    {
        String res = paymentService.paymentinfo_ok(id);
        log.info("res"+res);
        return res;
    }
    @GetMapping(value = "/payment/hystrix/timeout/{id}")
    public String paymentinfo_timeout (@PathVariable("id") Integer id)
    {
        String res = paymentService.paymentinfo_timeout(id);
        log.info("res"+res);
        return res;
    }

    //服务熔断
    @GetMapping(value = "/payment/Circuit/{id}")
    public String  paymentinfo_Circuit(@PathVariable("id") Integer id)
    {
        String s = paymentService.paymentCircuitBreaker(id);
        log.info("res*******"+s);
        return s;
    }
}
